package com.sskj.givecoin.v.activity;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.support.design.widget.BottomSheetDialog;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;

import com.sskj.givecoin.R;
import com.sskj.givecoin.adapter.slimadapter.IViewInjector;
import com.sskj.givecoin.adapter.slimadapter.SlimAdapter;
import com.sskj.givecoin.adapter.slimadapter.SlimInjector;
import com.sskj.givecoin.common.App;
import com.sskj.givecoin.common.Constants;
import com.sskj.givecoin.m.bean.FabiOrderBean;
import com.sskj.givecoin.p.activity.FabiSellDetailPresenter;
import com.sskj.givecoin.utils.BottomUpUtil;
import com.sskj.givecoin.utils.CheckUtil;
import com.sskj.givecoin.utils.ClickUtil;
import com.sskj.givecoin.utils.ImageUtil;
import com.sskj.givecoin.utils.RxSchedulersHelper;
import com.sskj.givecoin.utils.TipUtil;
import com.sskj.givecoin.utils.ToastUtil;
import com.sskj.givecoin.v.base.BaseActivity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;

import butterknife.BindView;
import io.reactivex.Flowable;
import io.reactivex.subscribers.DisposableSubscriber;

/**
 * 法币交易订单界面
 */
public class FabiSellDetailActivity extends BaseActivity<FabiSellDetailPresenter> {

    @BindView(R.id.tv_id_code)
    TextView tvIdCode;
    @BindView(R.id.tv_sale_to)
    TextView tvSaleTo;
    @BindView(R.id.tv_single_price)
    TextView tvSinglePrice;
    @BindView(R.id.tv_all_price)
    TextView tvAllPrice;
    @BindView(R.id.tv_desc)
    TextView tvDesc;
    @BindView(R.id.tv_control)
    TextView tvControl;
    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.tv_control_second)
    TextView tvControlSecond;
    @BindView(R.id.tv_notify)
    TextView tvNotify;
    @BindView(R.id.tv_order_remark)
    TextView tvOrderRemark;  // 购买人手机号
    @BindView(R.id.bt_control)
    Button btControl;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    private boolean isBuy;
    private HashMap<String, Integer> payMap;
    private String orderNum;
    private AlertDialog payTipDialog;
    private EditText etReason;
    private Spinner spinner;
    private FabiOrderBean orderData;
    private BottomSheetDialog codeDialog;
    private SlimAdapter<FabiOrderBean.PayListBean> slimAdapter;
    private DisposableSubscriber<Long> timeDispo;
    private int curPos;
    private HashMap<String, String> payTipMap;
    private AlertDialog tipCancleDialog;
    private AlertDialog tipAppealDialog;
    private AlertDialog qrDialog;
    private ImageView ivQR;
    private TextView tvQR;
    private DisposableSubscriber<Long> timerDispos;

    public static void start(Context context, String orderNum, boolean isBuy) {
        Intent starter = new Intent(context, FabiSellDetailActivity.class);
        starter.putExtra(Constants.ORDER_NUM, orderNum);
        starter.putExtra(Constants.IS_BUY, isBuy);
        context.startActivity(starter);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_fabi_sell_detail;
    }

    @Override
    public FabiSellDetailPresenter getPresenter() {
        return new FabiSellDetailPresenter();
    }

    @Override
    protected void initData() {
        payMap = new HashMap<>();
        payTipMap = new HashMap<>();
        payTipMap.put("wx", App.INSTANCE.getString(R.string.strFabiSellDetailActivity201));
        payTipMap.put("alipay", App.INSTANCE.getString(R.string.strFabiSellDetailActivity203));
        payMap.put("paypal", R.mipmap.pay_pal);
        payMap.put("wx", R.mipmap.wei_xin);
        payMap.put("alipay", R.mipmap.zhifu_bao);
        payMap.put("backcard", R.mipmap.yinhang_ka);
        orderNum = getIntent().getStringExtra(Constants.ORDER_NUM);
        isBuy = getIntent().getBooleanExtra(Constants.IS_BUY, true);
        mPresenter.getOrderInfo(orderNum, true);
        timerDispos = new DisposableSubscriber<Long>() {
            @Override
            public void onNext(Long aLong) {
                mPresenter.getOrderInfo(orderNum, false);
            }

            @Override
            public void onError(Throwable t) {

            }

            @Override
            public void onComplete() {

            }
        };
        Flowable.interval(10, 10, TimeUnit.SECONDS)
                .compose(RxSchedulersHelper.transformer())
                .subscribe(timerDispos);
    }

    @Override
    protected void initView() {
        mToolbar.setNavigationOnClickListener(v -> finish());
        mToolbar.setTitle(App.INSTANCE.getString(R.string.strFabiSellDetailActivity207));
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        slimAdapter = SlimAdapter.create().register(R.layout.recy_item_pay_type, new SlimInjector<FabiOrderBean.PayListBean>() {
            @Override
            public void onInject(FabiOrderBean.PayListBean data, IViewInjector injector) {
                injector.image(R.id.iv_pay_type, payMap.get(data.getType()))
                        .text(R.id.tv_pay_type, data.getTip())
                        .text(R.id.tv_pay_num, data.getNumber())
                        .text(R.id.tv_pay_name, data.getName())
                        .visibility(R.id.iv_pay_qrcode, "backcard".equals(data.getType()) || "paypal".equals(data.getType()) ? View.INVISIBLE : View.VISIBLE)  // 二维码
                        .visibility(R.id.ll_bank, "backcard".equals(data.getType()) ? View.VISIBLE : View.GONE)  // 银行列表
                        .clicked(R.id.iv_pay_qrcode, (v) -> {
                            curPos = slimAdapter.getData().indexOf(data);
                            showQR();
                        })
                        .with(R.id.ll_bank, (v) -> {
                            if ("backcard".equals(data.getType())) {
                                ((TextView) v.findViewById(R.id.tv_pay_big_bank)).setText(data.getBank());
                                ((TextView) v.findViewById(R.id.tv_pay_small_bank)).setText(data.getBranch());
                            } else {
                                ((TextView) v.findViewById(R.id.tv_pay_big_bank)).setText("");
                                ((TextView) v.findViewById(R.id.tv_pay_small_bank)).setText("");

                            }
                        });
            }
        }).attachTo(recyclerView).updateData(new ArrayList());

    }

    /**
     * 显示二维码弹窗
     */
    private void showQR() {
        FabiOrderBean.PayListBean dataItem = slimAdapter.getDataItem(curPos);
        if (qrDialog == null) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            View view = View.inflate(this, R.layout.dialog_erweima, null);
            ivQR = view.findViewById(R.id.iv_erweima);
            tvQR = view.findViewById(R.id.tv_content);
            builder.setView(view);
            builder.setCancelable(true);
            qrDialog = builder.create();
        }
        ImageUtil.setImage(dataItem.getImg(), ivQR);
        tvQR.setText(payTipMap.get(dataItem.getType()));
        qrDialog.show();
    }

    /**
     * 显示申诉弹窗
     */
    private void showAppeal() {
        if (tipAppealDialog == null) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            View view = View.inflate(this, R.layout.dialog_fabi_sell_detail_appeal, null);
            ClickUtil.click(view.findViewById(R.id.tv_cancel), () -> tipAppealDialog.dismiss());
            ClickUtil.click(view.findViewById(R.id.tv_apply), () -> {
                tipAppealDialog.dismiss();
                String type = spinner.getSelectedItem().toString();
                String reason = etReason.getText().toString();
                mPresenter.allegeOrder(orderNum, orderData.getRefer(), orderData.getOop_account(), type, reason);

            });
            builder.setView(view);
            builder.setCancelable(true);
            etReason = view.findViewById(R.id.et_reason);
            spinner = view.findViewById(R.id.spinner);
            tipAppealDialog = builder.create();
        }

        tipAppealDialog.show();
    }

    /**
     * 显示撤单提示
     */
    private void showCancelTip() {
        if (tipCancleDialog == null) {
            tipCancleDialog = new AlertDialog.Builder(this)
                    .setTitle(App.INSTANCE.getString(R.string.strFabiSellDetailActivity213))
                    .setMessage(App.INSTANCE.getString(R.string.strFabiSellDetailActivity214))
                    .setPositiveButton(App.INSTANCE.getString(R.string.strFabiSellDetailActivity215), (dialog, which) -> {
                        dialog.dismiss();
                        mPresenter.cancleOrder(orderData.getOrder_num());
                    })
                    .setNegativeButton(App.INSTANCE.getString(R.string.strFabiSellDetailActivity216), (dialog, which) -> dialog.dismiss()).create();
        }
        tipCancleDialog.show();
    }

    public void updateUI(FabiOrderBean data) {
        orderData = data;
        tvIdCode.setText(data.getOrder_num());
//        tvOrderRemark.setVisibility(isBuy ? View.VISIBLE : View.GONE);
//        tvOrderRemark.setText(String.format(App.INSTANCE.getString(R.string.strFabiSellDetailActivity217), data.getNotes()));
//        tvOrderRemark.setText(String.format(App.INSTANCE.getString(R.string.strFabiSellDetailActivity218), !TextUtils.isEmpty(data.getOop_mobile()) ? data.getOop_mobile() : App.INSTANCE.getString(R.string.strFabiSellDetailActivity219)));
        tvOrderRemark.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity220));
        ClickUtil.click(tvOrderRemark, () -> {
            if (!TextUtils.isEmpty(data.getOop_mobile())) {
                if (CheckUtil.isEmail(data.getOop_mobile())) {
                    ToastUtil.showShort(data.getOop_mobile());
                } else {
                    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + data.getOop_mobile()));
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                }
            }
        });
        tvSinglePrice.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity222) + data.getPrice() + "CNY/USDT");
        tvAllPrice.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity224) + data.getTotal_price() + "CNY");
        slimAdapter.updateData(data.getPay_list());
        btControl.setVisibility(View.VISIBLE);
        btControl.setEnabled(true);
        String leftTime;
        if ("3".equals(data.getStatus()) || "5".equals(data.getStatus())) {//完成或取消状态取消定时刷新
            if (timerDispos != null && !timerDispos.isDisposed()) {
                timerDispos.dispose();
            }
        }
        if (data.getDown_time() != 0 && ("1".equals(data.getStatus()) || "2".equals(data.getStatus()))) {
            if (timeDispo != null && !timeDispo.isDisposed()) {
                timeDispo.dispose();
                timeDispo = null;
            }
            timeDispo = new DisposableSubscriber<Long>() {
                @Override
                public void onNext(Long aLong) {
                    updateTime(aLong);
                }

                @Override
                public void onError(Throwable t) {
                    System.out.println(t);
                }

                @Override
                public void onComplete() {

                }
            };
            int downTimer = "2".equals(data.getStatus()) ? data.getQr_time() : data.getDown_time();
            Flowable.intervalRange(1, downTimer, 0, 1, TimeUnit.SECONDS)
                    .map(i -> downTimer - i)
                    .compose(RxSchedulersHelper.transformer())
                    .subscribe(timeDispo);


            if (data.getDown_time() > 60) {
                leftTime = data.getDown_time() / 60 + "分" + data.getDown_time() % 60 + "秒";
            } else {
                leftTime = "00分" + data.getDown_time() + "秒";
            }

        } else {
            leftTime = App.INSTANCE.getString(R.string.strFabiSellDetailActivity231);
        }

        if (isBuy) {
            tvSaleTo.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity232) + data.getOop_name() + App.INSTANCE.getString(R.string.strFabiSellDetailActivity233) + data.getTotal_num() + "USDT");
            switch (data.getStatus()) {
                case "1"://未确认待付款
                    if (leftTime.contains(getString(R.string.strFabiSellDetailActivity231))) {
                        tvDesc.setText(leftTime);
                    } else {
                        String desc = App.INSTANCE.getString(R.string.strFabiSellDetailActivity236) + leftTime + App.INSTANCE.getString(R.string.strFabiSellDetailActivity237) + data.getOop_name() + App.INSTANCE.getString(R.string.strFabiSellDetailActivity238) + data.getRefer() + "）";
                        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(desc);
                        spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.RED), desc.indexOf(leftTime), desc.indexOf(leftTime) + leftTime.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
                        tvDesc.setText(spannableStringBuilder);
                    }
                    tvNotify.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity240));
                    tvControl.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity241));
                    tvControlSecond.setText("");
                    btControl.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity243));
                    ClickUtil.click(tvControlSecond, () -> {
                    });
                    ClickUtil.click(tvControl, () -> showCancelTip());
                    ClickUtil.click(btControl, this::showPayTip);
                    break;
                case "2"://已付款
                    tvDesc.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity245) + data.getRefer() + "）");
                    if (leftTime.contains(getString(R.string.strFabiSellDetailActivity231))) {
                        tvNotify.setText(leftTime);
                    } else {
                        tvNotify.setText(leftTime + App.INSTANCE.getString(R.string.strFabiSellDetailActivity247));
                    }
                    tvControl.setText("");
                    tvControlSecond.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity249));
                    btControl.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity250));
                    ClickUtil.click(tvControl, () -> {
                    });
                    ClickUtil.click(tvControlSecond, this::showAppeal);
                    ClickUtil.click(btControl, () -> {
                    });
                    btControl.setEnabled(false);

                    break;
                case "3"://已确认完成
                    tvDesc.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity252) + data.getRefer() + "）");
                    tvNotify.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity254));
                    tvControl.setText("");
                    tvControlSecond.setText("");
                    btControl.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity257));
                    ClickUtil.click(tvControl, () -> {
                    });
                    ClickUtil.click(tvControlSecond, () -> {
                    });
                    ClickUtil.click(btControl, this::finish);
                    break;
                case "4"://申述中
                    tvDesc.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity259) + data.getCommand() + ",\n付款参考号：" + data.getRefer());
                    tvNotify.setText("");
                    tvControl.setText("");
                    tvControlSecond.setText("");
                    btControl.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity215));
                    ClickUtil.click(btControl, () -> {
                    });
                    ClickUtil.click(tvControlSecond, () -> {
                    });
                    ClickUtil.click(tvControl, this::finish);
                    btControl.setVisibility(View.INVISIBLE);
                    break;
                case "5"://订单取消
                    tvDesc.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity266));
                    tvNotify.setText("");
                    tvControl.setText("");
                    tvControlSecond.setText("");
                    btControl.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity270));
                    btControl.setVisibility(View.VISIBLE);
                    btControl.setEnabled(false);
                    ClickUtil.click(tvControl, () -> {
                    });
                    ClickUtil.click(tvControlSecond, () -> {
                    });
                    ClickUtil.click(btControl, () -> {
                    });
                    break;

            }
        } else {
            tvSaleTo.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity232) + data.getOop_name() + App.INSTANCE.getString(R.string.strFabiSellDetailActivity272) + data.getTotal_num() + "USDT");
            switch (data.getStatus()) {
                case "1"://未确认待付款


                    if (leftTime.contains(getString(R.string.strFabiSellDetailActivity231))) {
                        tvDesc.setText(leftTime);
                    } else {
                        String desc = App.INSTANCE.getString(R.string.strFabiSellDetailActivity275) + data.getOop_name() + App.INSTANCE.getString(R.string.strFabiSellDetailActivity276) + leftTime + "内完成支付，\n付款参考号：" + data.getRefer();
                        tvDesc.setText(desc);
                    }


                    tvNotify.setText("");
                    tvControl.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity241));
                    tvControlSecond.setText("");
                    btControl.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity281));
                    btControl.setEnabled(false);
                    ClickUtil.click(tvControlSecond, () -> {
                    });
                    ClickUtil.click(tvControl, () -> showCancelTip());
                    ClickUtil.click(btControl, () -> {
                    });
                    break;
                case "2"://已付款
                    tvDesc.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity283) + data.getRefer());
                    if (leftTime.contains(getString(R.string.strFabiSellDetailActivity231))) {
                        tvNotify.setText(leftTime);
                    } else {
                        tvNotify.setText(leftTime + App.INSTANCE.getString(R.string.strFabiSellDetailActivity247));
                    }
                    tvControl.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity249));
                    tvControlSecond.setText("");
                    btControl.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity287));
                    ClickUtil.click(tvControl, () -> {
                    });
                    ClickUtil.click(tvControl, this::showAppeal);
                    ClickUtil.click(btControl, this::showCode);
                    break;
                case "3"://已确认完成
                    tvDesc.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity252) + data.getRefer() + "）");
                    tvNotify.setText("");
                    tvControl.setText("");
                    tvControlSecond.setText("");
                    btControl.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity257));
                    ClickUtil.click(tvControl, () -> {
                    });
                    ClickUtil.click(tvControlSecond, () -> {
                    });
                    ClickUtil.click(btControl, this::finish);
                    break;
                case "4"://申述中
                    tvDesc.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity259) + data.getCommand() + ",\n付款参考号：" + data.getRefer());
                    tvNotify.setText("");
                    tvControl.setText("");
                    tvControlSecond.setText("");
                    btControl.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity215));
                    btControl.setVisibility(View.INVISIBLE);
                    ClickUtil.click(tvControl, () -> {
                    });
                    ClickUtil.click(tvControlSecond, () -> {
                    });
                    ClickUtil.click(btControl, () -> {
                    });
                    break;
                case "5"://订单取消
                    tvDesc.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity266));
                    tvNotify.setText("");
                    tvControl.setText("");
                    tvControlSecond.setText("");
                    btControl.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity270));
                    btControl.setVisibility(View.VISIBLE);
                    btControl.setEnabled(false);
                    ClickUtil.click(tvControl, () -> {
                    });
                    ClickUtil.click(tvControlSecond, () -> {
                    });
                    ClickUtil.click(btControl, () -> {
                    });
                    break;
            }

        }

    }

    /**
     * 更新剩余时间
     *
     * @param aLong
     */
    private void updateTime(Long aLong) {
        String leftTime;
        if (aLong <= 0) {
            leftTime = App.INSTANCE.getString(R.string.strFabiSellDetailActivity308);
        } else {
            if (aLong > 60) {
                leftTime = aLong / 60 + "分" + aLong % 60 + "秒";
            } else {
                leftTime = "00分" + aLong + "秒";
            }

        }
        if (isBuy) {
            tvSaleTo.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity232) + orderData.getOop_name() + App.INSTANCE.getString(R.string.strFabiSellDetailActivity233) + orderData.getTotal_num() + "USDT");
            switch (orderData.getStatus()) {
                case "1"://未确认待付款
                    if (leftTime.contains(getString(R.string.strFabiSellDetailActivity231))) {
                        tvDesc.setText(leftTime);
                    } else {
                        String desc = App.INSTANCE.getString(R.string.strFabiSellDetailActivity236) + leftTime + App.INSTANCE.getString(R.string.strFabiSellDetailActivity237) + orderData.getOop_name() + App.INSTANCE.getString(R.string.strFabiSellDetailActivity238) + orderData.getRefer() + "）";
                        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(desc);
                        spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.RED), desc.indexOf(leftTime), desc.indexOf(leftTime) + leftTime.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
                        tvDesc.setText(spannableStringBuilder);
                    }

                    break;
                case "2"://已付款
                    if (leftTime.contains(getString(R.string.strFabiSellDetailActivity231))) {
                        tvNotify.setText(leftTime);
                    } else {
                        tvNotify.setText(leftTime + App.INSTANCE.getString(R.string.strFabiSellDetailActivity247));
                    }
                    break;
                case "3"://已确认完成

                    break;
                case "4"://申述中
                    break;

            }
        } else {
            tvSaleTo.setText(App.INSTANCE.getString(R.string.strFabiSellDetailActivity232) + orderData.getOop_name() + App.INSTANCE.getString(R.string.strFabiSellDetailActivity272) + orderData.getTotal_num() + "USDT");
            switch (orderData.getStatus()) {
                case "1"://未确认待付款

                    if (leftTime.contains(getString(R.string.strFabiSellDetailActivity231))) {
                        tvDesc.setText(leftTime);
                    } else {
                        String desc = App.INSTANCE.getString(R.string.strFabiSellDetailActivity275) + orderData.getOop_name() + App.INSTANCE.getString(R.string.strFabiSellDetailActivity276) + leftTime + "内完成支付，\n付款参考号：" + orderData.getRefer();
                        tvDesc.setText(desc);
                    }

                    break;
                case "2"://已付款
                    if (leftTime.contains(getString(R.string.strFabiSellDetailActivity231))) {
                        tvNotify.setText(leftTime);
                    } else {
                        tvNotify.setText(leftTime + App.INSTANCE.getString(R.string.strFabiSellDetailActivity247));
                    }
                    break;
                case "3"://已确认完成
                    break;
                case "4"://申述中
                    break;

            }

        }
    }

    /**
     * 显示验证码底部弹窗
     */
    private void showCode() {
        if (codeDialog == null) {
            codeDialog = BottomUpUtil.getPay(this, mPresenter, (pwd) -> {
                codeDialog.dismiss();
                mPresenter.letGo(orderNum, pwd);
            });
        }
        codeDialog.show();

    }

    /**
     * 支付完成提示弹窗
     */
    private void showPayTip() {
        if (payTipDialog == null) {
            payTipDialog = TipUtil.customTip1(this, App.INSTANCE.getString(R.string.strFabiSellDetailActivity332),
                    App.INSTANCE.getString(R.string.strFabiSellDetailActivity333),
                    App.INSTANCE.getString(R.string.strFabiSellDetailActivity215), () -> mPresenter.markPay(orderNum));
        }
        payTipDialog.show();
    }

    public void back() {
        setResult(RESULT_OK);
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (timeDispo != null && !timeDispo.isDisposed()) {
            timeDispo.dispose();
            timeDispo = null;
        }
        if (timerDispos != null && !timerDispos.isDisposed()) {
            timerDispos.dispose();
            timerDispos = null;
        }

    }
}
